Create database OnlineOrderDigitalPhotoPrintting
Go
Use OnlineOrderDigitalPhotoPrintting
Go
Create table Users(
	userID varchar(50) primary key,
	userPassword varchar(50) not null,
	firtName nvarchar(50) not null,
	lastName nvarchar(50) not null,
	Birthday varchar(30) not null,
	Gender bit not null,
	Phone int not null,
	[Address] nvarchar(100) not null,
	Email varchar(100) not null,
	[Type] bit
)
Go
Create table Orders(
	orderID int identity primary key,
	userID varchar(50) not null,
	dateOrder datetime default getdate(),
	totalPrice int not null,
	[Address] nvarchar(100)
)
Go
Create table OrderDetail(
	orderID int not null,
	sizeID int not null,
	imageID int not null,
	Price int not null,
	Quantity int not null,
	totalPrice int not null
)
Go
Create table SizePrint(
	sizeID int identity primary key,
	sizeName varchar(20) not null,
	Price int not null
)
Go
Create table Images(
	imageID int identity primary key,
	imageUrl varchar(100) not null,
	userID varchar(50) not null
)
go
alter table Orders add constraint FK1 foreign key(userID) references Users(userID)
alter table Images add constraint FK2 foreign key(userID) references Users(userID)
alter table OrderDetail add constraint FK3 foreign key(orderID) references Orders(orderID) on delete cascade
alter table OrderDetail add constraint FK4 foreign key(sizeID) references SizePrint(sizeID)
alter table OrderDetail add constraint FK5 foreign key(imageID) references Images(imageID)

